package com.lovo.pis.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.lovo.pis.constant.MessageCode;
import com.lovo.pis.dto.CustomBean;
import com.lovo.pis.dto.PageBean;
import com.lovo.pis.service.ICustomService;
import com.lovo.pis.utils.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/custom")
public class CustomController {

    @Autowired
    ICustomService customService;
    //模糊分页查询所有
    @RequestMapping("/queryAll")
    public IPage<CustomBean> queryByItem(@RequestBody PageBean<CustomBean> pageInfo){
       return customService.queryByItem(pageInfo);
    }

    //查询所有名称
    @RequestMapping("/queryAllName")
    public List<CustomBean> queryAllName(){
        return customService.queryAllName();
    }

    //id查询单个
    @RequestMapping("/query")
    public CustomBean queryById(int id){
       return customService.queryById(id);
    }

    //id修改单个
    @RequestMapping("/change")
    public JsonResult  changeById(@RequestBody CustomBean customBean){
        JsonResult jsonResult = new JsonResult<>();
        customService.changeById(customBean);
        return jsonResult;
    }

    //添加
    @RequestMapping("/add")
    public JsonResult  addSupplier(@RequestBody CustomBean customBean){
        JsonResult jsonResult = new JsonResult<>();
        customService.addSupplier(customBean);
        return jsonResult;
    }

}
